package com.peanut.baby.mvp.qadetail;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.peanut.baby.R;
import com.peanut.baby.model.QAComment;
import com.peanut.baby.mvp.profile.ProfileActivity;
import com.peanut.baby.util.TimeUtil;
import com.peanut.devlibrary.imageloader.ImageLoader;
import com.peanut.devlibrary.widget.pullrecycle.BaseRecyclerAdapter;
import com.peanut.devlibrary.widget.pullrecycle.BaseViewHolder;

import java.util.List;

/**
 * Created by anonymouslystudio on 2017/7/17.
 */

public class QACommentListAdapter extends BaseRecyclerAdapter<QAComment> {



    public QACommentListAdapter(Context context, List<QAComment> data) {
        super(context,data);
    }

    @Override
    protected void convert(BaseViewHolder holder, QAComment item, int position) {
        super.convert(holder, item, position);

    }


    @Override
    protected void convert(BaseViewHolder holder, final QAComment item) {
        TextView nick = holder.getView(R.id.comment_nick);

        TextView time = holder.getView(R.id.comment_time);
        TextView content = holder.getView(R.id.comment_content);
        ImageView avatar = holder.getView(R.id.comment_avatar);

        nick.setText(item.creatorNickname);
        time.setText(TimeUtil.getDisplayTimeMillis(item.createTime));
        content.setText(item.content);
        ImageLoader.getInstance().loadImageView(mContext,item.creatorAvatar,avatar);

        avatar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ProfileActivity.start(mContext,item.userId);
            }
        });

    }

    @Override
    protected int getLayoutId() {
        return R.layout.layout_item_qa_comment;
    }
}